﻿using System;
using System.Text;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using System.Collections.Generic;
using UnityEngine.InputSystem;
using DG.Tweening;

namespace Super
{
	/// <summary>
	/// 编辑器方法拓展，让系统的基类有更多的调用方法
	/// 使用方法：创建对象的实例，通过实例即可调用扩展方法
	/// 不判空，有问题直接报错，方便找到位置修改
	/// </summary>
	public static class EngineExtension
	{
		/// <summary>
		/// 获取双项链表的第n个对象
		/// </summary>
		/// <param name="list"></param>
		/// <param name="index"></param>
		/// <typeparam name="T"></typeparam>
		/// <returns></returns>
		public static T GetIndex<T>(this LinkedList<T> list, int index)
		{
			var node = list.First;
			for (int i = 0; i < index; i++)
			{
				node = node.Next;
			}
			return node.Value;
			
		}
		
		public static void DelayInvoke(this Action action, float delay)
		{			
			Sequence seq = DOTween.Sequence();
			seq.AppendInterval(delay);
			seq.AppendCallback(() => action());
		}
	}
}
